package a.f.h.f.a;

import a.c.*;
import a.c.d;
import a.f.j.cb;
import a.f.j.o;

import java.util.ArrayList;

public class f
{
  private cb a;
  private q b;
  private ab c;
  private boolean d;
  private e f;
  private a.c.e g = null;
  private a.c.e h = null;
  public static final int i = 0;
  public static final int j = 1;
  public static final int k = 2;
  public static final int l = 1;
  public static final int m = 0;
  public static final int n = 2;
  public static int o;
  
  public f(cb paramcb, e parame)
  {
    this.f = parame;
    this.a = paramcb;
    this.b = paramcb.a();
    this.c = new ab();
    this.d = false;
  }
  
  public ab a()
  {
    if ((e.i != 0) || (this.d)) {
      return this.c;
    }
    throw new RuntimeException("Invalid Execution Order: call 'assignUpward' first!");
  }
  
  public a.c.e b()
  {
    if ((e.i != 0) || (this.d)) {
      return this.g;
    }
    throw new RuntimeException("Invalid Execution Order: call 'assignUpward' first!");
  }
  
  public a.c.e c()
  {
    if ((e.i != 0) || (this.d)) {
      return this.h;
    }
    throw new RuntimeException("Invalid Execution Order: call 'assignUpward' first!");
  }
  
  public void d()
  {
    int i1 = e.i;
    boolean bool = e.h;
    z localz = new z();
    a.i.n.a(this, 0, "STARTING ST-AUGMENTATION");
    if (i1 == 0)
    {
      if (!a.a.m.c(this.b)) {
        throw new RuntimeException("graph is not connected: cannot handle this yet!");
      }
      h();
    }
    o localo = this.a.b();
    if (localo.e()) {}
    while (i1 != 0)
    {
      localz.add(localo.a());
      localo.f();
      if ((i1 == 0) && (bool)) {
        return;
      }
      if (!bool) {
        break;
      }
    }
    if (!localz.isEmpty()) {}
    do
    {
      a(localz, this.a.c());
      if ((i1 == 0) && (bool)) {
        return;
      }
      if (!bool) {
        break;
      }
      e();
      g();
      this.d = true;
    } while (i1 != 0);
    i();
  }
  
  private void e()
  {
    int i7 = e.i;
    boolean bool = e.h;
    ab localab1 = new ab();
    ab localab2 = new ab();
    ab localab3 = new ab();
    a.i.n.a(this, 0, "AUGMENTING OUTER FACE");
    Object localObject1 = new ArrayList();
    ArrayList localArrayList = new ArrayList();
    String str = "";
    x localx = this.b.B();
    a.c.m localm1 = this.a.c().a();
    d locald1 = localm1.a();
    label394:
    label482:
    do
    {
      Object localObject2;
      a.c.e locale;
      d locald3;
      while (localm1.e())
      {
        localObject2 = localm1.a();
        locale = ((d)localObject2).f();
        int i2 = this.f.a((d)localObject2);
        localm1.b();
        locald3 = localm1.a();
        int i3 = this.f.a(locald3);
        a.i.n.a(this, 1, "currentNode: " + locale);
        a.i.n.a(this, 1, "  inedge: " + localObject2 + " direction: " + i2);
        a.i.n.a(this, 1, "  outedge: " + locald3 + "  direction: " + i3);
        if (i2 != i3)
        {
          if (i2 == 1)
          {
            if (locald3 == this.f.a(locald3.e()))
            {
              str = str.concat("L");
              a.i.n.a(this, 2, "  1.1 angle is large");
              if (i7 != 0) {
                break label394;
              }
              if (!bool) {}
            }
            else
            {
              str = str.concat("S");
              a.i.n.a(this, 2, "  1.2 angle is small");
              if (i7 != 0) {
                break label394;
              }
              if (!bool) {}
            }
          }
          else if (locald3 == this.f.b(locald3.e()))
          {
            str = str.concat("L");
            a.i.n.a(this, 2, "  2.1 angle is large");
            if (i7 != 0) {
              break label394;
            }
            if (!bool) {}
          }
          else
          {
            str = str.concat("S");
            a.i.n.a(this, 2, "  2.2 angle is small");
          }
          int i5 = 0;
          int i6 = 0;
          a.c.m localm2 = locale.n();
          do
          {
            do
            {
              if (!localm2.e()) {
                break label482;
              }
              int i4 = this.f.a(localm2.a());
              if (bool) {
                break;
              }
              if (i4 == 1)
              {
                i5++;
                if (i7 != 0) {
                  continue;
                }
                if (!bool) {}
              }
              else
              {
                if (i7 != 0) {
                  continue;
                }
                if (i4 == 2) {
                  i6++;
                }
              }
              localm2.f();
            } while (!bool);
          } while (i7 != 0);
          if (i7 == 0) {
            if (i5 == 0)
            {
              if (i7 != 0) {
                break label554;
              }
              if (i6 > 0)
              {
                a.i.n.a(this, 0, locale + " is SINK");
                localx.a(locale, 2);
                if (i7 != 0) {
                  break label670;
                }
                if (!bool) {
                  break label652;
                }
              }
            }
          }
          if ((i7 != 0) || (i5 > 0)) {
            if (i7 == 0)
            {
              if (i6 == 0)
              {
                a.i.n.a(this, 0, locale + " is SOURCE");
                localx.a(locale, 0);
              }
            }
            else
            {
              if (i7 != 0) {
                break label670;
              }
              if (!bool) {
                break label652;
              }
            }
          }
          a.i.n.a(this, 0, locale + " is INTERNAL NODE");
          localx.a(locale, 1);
          ((ArrayList)localObject1).add(locale);
          localArrayList.add(localObject2);
          if (!bool) {}
        }
        else
        {
          a.i.n.a(this, 0, locale + " is an INTERNAL NODE");
        }
        if (locald3 == locald1) {
          break;
        }
      }
      ((ArrayList)localObject1).add(((ArrayList)localObject1).get(0));
      localArrayList.add(localArrayList.get(0));
      ((ArrayList)localObject1).add(((ArrayList)localObject1).get(1));
      localArrayList.add(localArrayList.get(1));
      str = str.concat(str.substring(0, 2));
      a.i.n.a(this, 0, "*** lSymbolSequence: " + str);
      int i1 = str.indexOf("LSL");
      if (i7 == 0)
      {
        if (i1 != -1) {
          a.i.n.a(this, 0, "startindex: " + i1);
        }
      }
      else
      {
        localObject2 = (a.c.e)((ArrayList)localObject1).get(i1);
        locale = (a.c.e)((ArrayList)localObject1).get(i1 + 2);
        d locald2 = (d)localArrayList.get(i1);
        locald3 = (d)localArrayList.get(i1 + 2);
        if (localx.getInt(localObject2) == 0)
        {
          locald4 = this.b.a((a.c.e)localObject2, locale);
          this.a.o(locald4);
          this.a.a(this.a.c(), locald4, locald2, locald3);
          this.f.a(locald4, 1);
          this.f.a(this.a.b(locald4), 2);
          this.a.a(this.a.c(locald4));
          this.f.c((a.c.e)localObject2, locald4);
          this.f.a(locale, this.a.b(locald4));
          localab3.add(this.a.b(locald4));
          this.c.add(locald4);
          localab1.add(locald4);
          this.g = ((a.c.e)localObject2);
          a.i.n.a(this, 0, "connected " + localObject2 + " with " + locale);
          localx.a(locale, 1);
          if (i7 != 0) {
            break label1320;
          }
          if (!bool) {
            break;
          }
        }
        d locald4 = this.b.a(locale, (a.c.e)localObject2);
        this.a.o(locald4);
        this.a.a(this.a.c(), locald4, locald2, locald3);
        this.f.a(locald4, 1);
        this.f.a(this.a.b(locald4), 2);
        this.a.a(this.a.c(this.a.b(locald4)));
        this.f.c(locale, locald4);
        this.f.a((a.c.e)localObject2, this.a.b(locald4));
        localab3.add(this.a.b(locald4));
        this.c.add(locald4);
        localab2.add(locald4);
        this.h = ((a.c.e)localObject2);
        a.i.n.a(this, 0, "connected " + locale + " with " + localObject2);
        localx.a(localObject2, 1);
        if (!bool) {
          break;
        }
      }
    } while (i7 != 0);
    label554:
    localObject1 = localab1.l();
    label652:
    label670:
    label1320:
    do
    {
      do
      {
        if (!((a.c.m)localObject1).e()) {
          break;
        }
        this.f.a(((a.c.m)localObject1).a(), 1);
        ((a.c.m)localObject1).f();
        if (i7 != 0) {
          break label1399;
        }
        if (bool) {
          break label1392;
        }
      } while (!bool);
    } while (i7 != 0);
    localObject1 = localab2.l();
    label1392:
    label1399:
    do
    {
      do
      {
        if (!((a.c.m)localObject1).e()) {
          break;
        }
        this.f.a(((a.c.m)localObject1).a(), 1);
        ((a.c.m)localObject1).f();
        if (i7 != 0) {
          break label1457;
        }
        if (bool) {
          break label1450;
        }
      } while (!bool);
    } while (i7 != 0);
    localObject1 = localab3.l();
    label1450:
    label1457:
    if (((a.c.m)localObject1).e()) {}
    do
    {
      this.f.a(((a.c.m)localObject1).a(), 2);
      ((a.c.m)localObject1).f();
      if ((i7 == 0) && (bool)) {
        return;
      }
      if (!bool) {
        break;
      }
      this.a.e();
    } while (i7 != 0);
    this.b.a(localx);
  }
  
  private void g()
  {
    int i4 = e.i;
    boolean bool = e.h;
    w localw = this.b.v();
    label136:
    label166:
    label190:
    do
    {
      if (!localw.e()) {
        break;
      }
      int i2 = 0;
      int i3 = 0;
      a.c.e locale = localw.d();
      a.c.m localm = locale.n();
      do
      {
        if (!localm.e()) {
          break;
        }
        int i1 = this.f.a(localm.a());
        if ((i4 == 0) && (bool)) {
          break label136;
        }
        if (i4 == 0)
        {
          if (i1 == 1)
          {
            i2++;
            if (i4 != 0) {
              continue;
            }
            if (!bool) {}
          }
          else
          {
            if (i4 != 0) {
              continue;
            }
          }
        }
        else if (i1 == 2) {
          i3++;
        }
        localm.f();
      } while (!bool);
      if ((i4 == 0) && (i2 == 0))
      {
        if (i4 != 0) {
          break label166;
        }
        if (i3 > 0)
        {
          this.h = locale;
          if (i4 != 0) {
            continue;
          }
          if (!bool) {
            break label190;
          }
        }
      }
      if (i4 == 0)
      {
        if (i2 > 0)
        {
          if (i4 != 0) {
            continue;
          }
          if (i3 == 0) {
            this.g = locale;
          }
        }
        localw.f();
      }
    } while (!bool);
  }
  
  private void h()
  {
    int i7 = e.i;
    boolean bool = e.h;
    o localo = this.a.b();
    label243:
    do
    {
      if (!localo.e()) {
        break;
      }
      int i3 = 0;
      int i4 = 0;
      a.c.e locale = null;
      a.c.m localm = localo.a().a();
      d locald3 = localm.a();
      a.c.e[] arrayOfe = new a.c.e[localm.k() + 2];
      d[] arrayOfd = new d[localm.k() + 2];
      int[] arrayOfInt = new int[localm.k() + 2];
      int i5 = 0;
      String str = "";
      while (localm.e())
      {
        d locald1 = localm.a();
        locale = locald1.f();
        int i1 = this.f.a(locald1);
        localm.b();
        d locald2 = localm.a();
        int i2 = this.f.a(locald2);
        if ((i7 != 0) || (i1 != i2))
        {
          if (i1 == 1)
          {
            if (locald2 == this.f.a(locald2.e()))
            {
              str = str.concat("L");
              i3++;
              if (i7 != 0) {
                break label243;
              }
              if (!bool) {}
            }
            else
            {
              str = str.concat("S");
              i4++;
            }
            arrayOfInt[i5] = 2;
            if (i7 != 0) {
              break label314;
            }
            if (!bool) {}
          }
          else
          {
            if (locald2 == this.f.b(locald2.e()))
            {
              str = str.concat("L");
              i3++;
              if (i7 == 0) {
                if (!bool) {
                  break label295;
                }
              }
            }
            else
            {
              str = str.concat("S");
            }
            i4++;
            arrayOfInt[i5] = 0;
          }
          arrayOfe[i5] = locale;
          arrayOfd[i5] = locald1;
          i5++;
        }
        if (locald2 == locald3) {
          break;
        }
      }
      int i6 = i3 - i4;
      if (i7 == 0)
      {
        if (i6 == -2)
        {
          a.i.n.a(this, 0, "Face " + localo.a() + " is internal !");
          if (i7 != 0) {
            continue;
          }
          if (!bool) {
            break label519;
          }
        }
        if (i7 != 0) {}
      }
      else
      {
        if (i6 != 2) {
          break label457;
        }
        a.i.n.a(this, 0, "Face " + localo.a() + " is external !");
        this.a.a(localo.a());
      }
      if (i7 == 0)
      {
        if (bool) {
          throw new RuntimeException("sum of angles (" + i6 + ") (L: " + i3 + " S: " + i4 + ") wrong in face: " + localo.a());
        }
        localo.f();
      }
    } while (!bool);
    label295:
    label314:
    label457:
    return;
  }
  
  private void a(z paramz, a.f.j.n paramn)
  {
    int i12 = e.i;
    boolean bool = e.h;
    int i5 = 0;
    int i6 = 0;
    int i7 = 0;
    int i8 = 0;
    a.f.j.n localn = (a.f.j.n)paramz.b();
    a.c.e locale1 = null;
    a.c.m localm1 = localn.a();
    d locald1 = localm1.a();
    a.c.e[] arrayOfe = new a.c.e[localm1.k() + 2];
    d[] arrayOfd = new d[localm1.k() + 2];
    int[] arrayOfInt = new int[localm1.k() + 2];
    int i9 = 0;
    String str = "";
    a.i.n.a(this, 0, "\nSATURATE FACE: " + localn);
    while (localm1.e())
    {
      d locald2 = localm1.a();
      locale1 = locald2.f();
      int i1 = this.f.a(locald2);
      localm1.b();
      d locald3 = localm1.a();
      int i2 = this.f.a(locald3);
      if ((i12 != 0) || (i1 != i2))
      {
        if (i1 == 1)
        {
          if (locald3 == this.f.a(locald3.e()))
          {
            str = str.concat("L");
            i7++;
            if (i12 != 0) {
              break label271;
            }
            if (!bool) {}
          }
          else
          {
            str = str.concat("S");
            i8++;
          }
          arrayOfInt[i9] = 2;
          i6++;
          if (i12 != 0) {
            break label348;
          }
          label271:
          if (!bool) {}
        }
        else
        {
          if (locald3 == this.f.b(locald3.e()))
          {
            str = str.concat("L");
            i7++;
            if (i12 != 0) {
              break label331;
            }
            if (!bool) {}
          }
          else
          {
            str = str.concat("S");
            i8++;
          }
          arrayOfInt[i9] = 0;
          label331:
          i5++;
        }
        arrayOfe[i9] = locale1;
        arrayOfd[i9] = locald2;
        label348:
        i9++;
      }
      if (locald3 == locald1) {
        break;
      }
    }
    int i10 = Math.abs(i7 - i8);
    if (i12 == 0)
    {
      if ((i10 != 2) && (localn != paramn)) {
        throw new RuntimeException("sum of angles (" + i10 + ") (L: " + i7 + " S: " + i8 + ") wrong in face: " + localn);
      }
      if (i12 != 0) {}
    }
    else
    {
      if (i5 == 1)
      {
        if (i12 != 0) {
          break label553;
        }
        if (i6 == 1)
        {
          a.i.n.a(this, 0, "only one source and one sink -> face saturation not necessary!");
          return;
        }
      }
      arrayOfe[i9] = arrayOfe[0];
      arrayOfd[i9] = arrayOfd[0];
      arrayOfInt[i9] = arrayOfInt[0];
      i9++;
      arrayOfe[i9] = arrayOfe[1];
      arrayOfd[i9] = arrayOfd[1];
      arrayOfInt[i9] = arrayOfInt[1];
      str = str.concat(str.substring(0, 2));
    }
    label553:
    int i3 = str.indexOf("LSS");
    if (i12 == 0) {
      if (i3 == -1)
      {
        if (localn == paramn) {
          return;
        }
        throw new RuntimeException("LSS not found in " + localn + " Sequence is " + str);
      }
    }
    int i4 = i3 + 2;
    ab localab1 = new ab();
    ab localab2 = new ab();
    a.c.e locale2 = arrayOfe[i3];
    a.c.e locale3 = arrayOfe[i4];
    d locald4 = arrayOfd[i3];
    d locald5 = arrayOfd[i4];
    int i11 = arrayOfInt[i3];
    d locald6 = null;
    if (i11 == 0) {
      locald6 = this.b.a(locale3, locale2);
    } else {
      locald6 = this.b.a(locale2, locale3);
    }
    this.a.o(locald6);
    a.f.j.n[] arrayOfn = this.a.a(localn, locald6, locald4, locald5);
    if (i12 == 0)
    {
      if (i11 == 0)
      {
        this.f.a(locale2, this.a.b(locald6));
        if (i12 != 0) {
          break label1018;
        }
        if (localn == paramn)
        {
          this.a.a(this.a.c(this.a.b(locald6)));
          if (i12 != 0) {
            break label1017;
          }
          if (!bool) {}
        }
      }
      else
      {
        this.f.c(locale2, locald6);
      }
    }
    else
    {
      if (i12 != 0) {
        break label1018;
      }
      if (localn == paramn) {
        this.a.a(this.a.c(locald6));
      }
    }
    this.f.a(locald6, 1);
    this.f.a(this.a.b(locald6), 2);
    a.i.n.a(this, 0, "  inserted edge " + locald6 + " direction " + this.f.a(locald6));
    a.i.n.a(this, 0, "  reverse edge  " + this.a.b(locald6) + " direction " + this.f.a(this.a.b(locald6)));
    paramz.add(arrayOfn[0]);
    paramz.add(arrayOfn[1]);
    this.c.add(locald6);
    localab1.add(locald6);
    label1017:
    localab2.add(this.a.b(locald6));
    label1018:
    a.c.m localm2 = localab1.l();
    do
    {
      do
      {
        if (!localm2.e()) {
          break;
        }
        this.f.a(localm2.a(), 1);
        localm2.f();
        if (i12 != 0) {
          break label1091;
        }
        if (bool) {
          break label1084;
        }
      } while (!bool);
    } while (i12 != 0);
    localm2 = localab2.l();
    label1084:
    label1091:
    do
    {
      if (!localm2.e()) {
        break;
      }
      this.f.a(localm2.a(), 2);
      localm2.f();
    } while (!bool);
  }
  
  private void i()
  {
    int i1 = e.i;
    if (i1 == 0)
    {
      if (!this.f.d()) {
        throw new RuntimeException("No st-graph !");
      }
      if (i1 != 0) {}
    }
    else if (!this.a.h())
    {
      throw new RuntimeException("Not planar !");
    }
    if (i1 == 0) {
      if (this.g == null) {
        throw new RuntimeException("No global source defined !");
      }
    }
    if (this.h == null) {
      throw new RuntimeException("No global sink defined !");
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.h.f.a.f

 * JD-Core Version:    0.7.0.1

 */